package com.company.cloud.work.modules.jobHandler;

import com.company.cloud.common.redis.service.RedisUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class WorkLogTaskJob {

    private static Logger logger = LoggerFactory.getLogger(WorkLogTaskJob.class);

    @Autowired
    private RedisUtils redisUtils;

//    @Autowired
//    private WorkScheduleInfoService workScheduleInfoService;

    /**
     * crm日程提醒
     */
//    @XxlJob("crmWorkScheduleHandler")
//    public ReturnT<String> crmWorkScheduleRemind(String param) throws Exception {
//        List<WorkScheduleInfo> workScheduleList = workScheduleInfoService.list(new QueryWrapper<WorkScheduleInfo>()
//                .le("str_to_date(start_date, '%Y-%m-%d')", LocalDateTime.now())
//                .ge("str_to_date(end_date, '%Y-%m-%d')", LocalDateTime.now())
//                .eq("is_receipt", BaseConstant.YNEnum.NO.getCode())
//                .eq("rows_state", BaseConstant.EnabledEnum.ENABLED.getCode())
//        );
//        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//        for (WorkScheduleInfo workScheduleInfo : workScheduleList) {
//            LocalDateTime endDate = LocalDateTime.parse(workScheduleInfo.getEndDate(), df);
//            Duration duration = Duration.between(LocalDateTime.now(), endDate);
//            // 发送消息 TODO
//            if (Long.parseLong(workScheduleInfo.getRemindDates()) <= duration.toDays()) {
//            }
//        }
////        XxlJobLogger.log("[crm日程提醒] - 执行成功");
//        return ReturnT.SUCCESS;
//    }

    public void init() {
        logger.info("init");
    }

    public void destroy() {
        logger.info("destory");
    }

}
